﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FingerprintAttendance
{
    public partial class FingerprintSetting : Form
    {
        System.Data.SQLite.SQLiteDataAdapter da;
        DataSet ds = new DataSet();

        public FingerprintSetting()
        {
            InitializeComponent();
        }

        private void FingerprintSetting_Load(object sender, EventArgs e)
        {
            da = DataOperation.GetFingerprintSettings(ds);
            dgvFingerprintSetting.DataSource = ds.Tables[0];
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (ds.HasChanges())
            {
                try
                {
                    da.Update(ds.Tables[0]);
                    ds.Tables[0].AcceptChanges();
                    DBHelper.conn.Close();
                    MessageBox.Show("更新成功！", "操作结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    DBHelper.conn.Close();
                    MessageBox.Show(ex.Message, "更新失败！", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
